package com.gugee.tiktok.common.model.system;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: luolifeng
 * Date: 2020-10-14 19:17
 */
@Data
@Component
public class SystemInfo {
    @Value("${spring.application.name}")
    private String appName;
    private String hostname;
    private String ip;
    @Value("${server.port}")
    private String port;
    public SystemInfo(){
        InetAddress address = null;
        try {
            address = InetAddress.getLocalHost();

        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        hostname=address==null?"":address.getHostAddress();
    }
    public String getSystemInfo(){
        return hostname+":"+port+":"+appName;
    }
}
